package com.rg1906.dao.Impl;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import com.rg1906.utils.DataSourceC3P0ThreadLocal;

public class UpdateTeacherDaoImpl {
	DataSource dataSource = DataSourceC3P0ThreadLocal.getDataSource();
	QueryRunner qr = new QueryRunner(dataSource);
	public int updateTeacher(String id, String teacherName, int gid, String phone, String sex, String age,
			String address) throws SQLException {
		String sql="update t_teacher set teacherName=?,gid=?,phone=?,sex=?,age=?,address=? where id=?";
		Object[] par= {teacherName,gid,phone,sex,age,address,id};
		return qr.update(sql,par);
	}
	public int updateGid(String gradeName) throws SQLException {
		String sql="select id from t_grade where gradename=? ";
		return qr.query(sql,new ScalarHandler<>(),gradeName);
	}
}
